package PTA6.ti4;

/**
 * @author Lenovo
 */

import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if (str.equals("other"))
                break;
            if (!str.equals("new")) {
                System.out.println("java.util.NoSuchElementException");
                continue;
            }
            if (str.equals("new")) {
                str = sc.nextLine();
                String letters[] = str.split(" ");
                if (letters.length == 1) {        //只有一个数据，打印如下异常
                    System.out.println("java.util.NoSuchElementException");
                    continue;
                }

                Student student = new Student(letters[0], Integer.valueOf(letters[1]));
                try {
                    student.setname(letters[0]);
                } catch (IllegalNameException e) {
                    System.out.println(e.getMessage());
                    continue;
                }

                try {
                    student.addScore(Integer.valueOf(letters[1]));
                } catch (IllegalScoreException e) {
                    System.out.println(e.getMessage());
                    continue;
                }
                System.out.println(student);
            }
        }
        System.out.println("scanner closed");
        sc.close();

    }
}


class Student {
    private String name;
    private int score;

    @Override
    public String toString() {
        return "Student " + "[name=" + name + ", " + "score=" + score + "]";
    }

    public int getscore() {
        return score;
    }

    public void setscore(int s) {
        score = s;
    }

    public String getname() {
        return name;
    }

    public String setname(String n) throws IllegalNameException {
        //如果第一个字母是数字
        if (Character.isDigit((n.charAt(0)))) {
            throw new IllegalNameException("IllegalNameException: the first char of name must not be digit, name=" + name);
        } else
            return n;
    }

    public int addScore(int score) throws IllegalScoreException {
        if (score < 0 || score > 100) {
            throw new IllegalScoreException("IllegalScoreException: score out of range, score=" + score);
        } else
            return score;
    }

    //带参的构造方法
    public Student(String name, int score) {
        this.name = name;
        this.score = score;
    }
}

//两个异常类的创建
class IllegalNameException extends Exception {
    public IllegalNameException(String n) {
        super(n);
    }
}

class IllegalScoreException extends Exception {
    public IllegalScoreException(String n) {
        super(n);
    }
}
